﻿<MCard Flat
       Color="transparent">
    <MSubheader>Rules</MSubheader>

    <MCardText class="pt-0">
        <MSlider @bind-Value="_value"
                 ErrorMessages="_errorMessages"
                 Label="How many?"
                 Step="10"
                 ThumbLabel="@("always")"
                 Ticks="true"
                 TValue="double"
                 OnChange="HandleOnChange"></MSlider>
    </MCardText>

    <MSubheader>Persistent hint</MSubheader>

    <MCardText class="pt-0">
        <MSlider @bind-Value="_value"
                 ErrorMessages="_errorMessages"
                 Hint="40 in stock"
                 Label="How many?"
                 PersistentHint
                 Step="10"
                 ThumbLabel="@("always")"
                 Ticks="true"
                 TValue="double"
                 OnChange="HandleOnChange"></MSlider>
    </MCardText>
</MCard>

  @code {
    private double _value = 30;
    private List<string> _errorMessages = new List<string>();

    public void HandleOnChange(double val)
    {
        _value = val;
        if (_value <= 40)
        {
            _errorMessages = new List<string>();
        }
        else
        {
            _errorMessages = new List<string>
                {
                    "Only 40 in stock"
                };
        }
    }
  }